import { Injectable, Pipe ,PipeTransform } from '@angular/core';
import * as moment from 'moment';

@Pipe({
  name: 'getWeak'
})
@Injectable()
export class GetWeak implements PipeTransform{
  constructor(){}

  transform(param) {
    if(param!=undefined){
      param = param.substring(0,8);
      let time = moment(param).format('YYYY-MM-DD');
      let date = new Date(time);
      let day = date.getDay();
      switch (day){
        case 1:
          return '周一';
        case 2:
          return '周二';
        case 3:
          return '周三';
        case 4:
          return '周四';
        case 5:
          return '周五';
        case 6:
          return '周六';
        case 0:
          return '周日';
      }
    }else{
      return "";
    }
  }
}
